package com.camps.sdk.decrypt;

import com.camps.sdk.common.Constants;
import com.camps.sdk.entity.DeviceUpMessage;
import com.camps.sdk.entity.NoLocateHeart;

/**
 * @Author ldaoliang
 * @Date create in 15:58 2021/9/1
 * @Description
 */
public class AnalyzeNoLocatedHeartBeat implements AnalyticalData {
    @Override
    public DeviceUpMessage parseData(String originalData) {
        //解密
        String[] split = parseCommand(originalData);
        String imei=split[1];
        String commandNumber=split[3];
        String gsm=split[4];//协议中返回的事gsm，不知道是什么暂不处理
        String gpsnum=split[5];
        String battery=split[6];//电量
        String stepNum=split[7];//MCC
        String mnc=split[8];//MCC
        String ta=split[9];//MCC
        String num=split[10];//MCC
        String lac=split[11];//MCC
        String cellId=split[12];//MCC
        String rxlev=split[13];//设备返回指令时间（时分秒）
        String date = split[15];//日月年
        String deviceStatus = split[16];//设备状态
        NoLocateHeart noLocateHeart = new NoLocateHeart();
        noLocateHeart.setImei(imei);
        noLocateHeart.setCommandNumber(commandNumber);
        noLocateHeart.setBattery(Integer.parseInt(battery));
        noLocateHeart.setDeviceDate(date);
        noLocateHeart.setDeviceTime(commandNumber);
        noLocateHeart.setStepNum(Integer.parseInt(stepNum));
        noLocateHeart.setDeviceStatus(deviceStatus);
        noLocateHeart.setCellId(cellId);
        noLocateHeart.setGsm(gsm);
        noLocateHeart.setMnc(mnc);
        noLocateHeart.setTa(ta);
        noLocateHeart.setNum(num);
        noLocateHeart.setLac(lac);
        noLocateHeart.setGpsNum(Integer.parseInt(gpsnum));
        String str="*WT,".concat(imei).concat(",KA,").concat(commandNumber).concat("#");
        return structureMessage(Constants.UPLOAD,Constants.UP_NO_LOCATED_HEARTBEAT,true,str,noLocateHeart);
    }
}
